#include "stdafx.h"

void game_machine :: cast_launch (short emit, short abil, short target)
{
    // In this function we finalize casting for both charging and cooldown spells
    LOGMSG("[launch] "+ inspect_cast(emit, abil, target));

    size_t pos;
    pool_timer(pos);
    Abilities[abil].on_cooldown = true;
    
    Timers[pos].abil = abil;
    Timers[pos].emit = emit;
    Timers[pos].target = target;
    
    if(Abilities[abil].cooltime < 0.0f) // cooldown spell
    {
        LOGMSG("Cooldown timer "+TO_STR(pos));
        Timers[pos].state = cooldown;
        Timers[pos].delay = - Abilities[abil].cooltime;
        
        
        bar.period = - Abilities[abil].cooltime;
        bar.current = 0;
        bar.inverse = 1.0f / - Abilities[abil].cooltime;
    }
    if(Abilities[abil].velocity == 0) // instant travel
        cast_land(emit, abil, target);
    //else
    // spawn_timer     // launch missile with missile_mgr or smth.
}